<template>
    <div class="subscribers">
        <div class="subscriber"
        v-for="(item,index) in subscribers"
        :key="index"
        
        >
            <img :src="item.avatarUrl" alt="" @load="show">
            <div class="name">{{item.nickname | nickNameFormat}}</div>
        </div>
        <!--分页-->
        <div class="paging" v-if="flag">
            <el-pagination
            background 
            :page-size="60"
            :page-count="pagerCount"
            :pager-count="7"
            layout="prev, pager, next"
            :total="total"
            @current-change="pageChange"
            >
            </el-pagination>
        </div>
    </div>
</template>

<script>
import {_getPlaylistSubscribers} from '../../../network/detail'
export default {
    name: 'subscribers',
    props: [
        'subscribedCount'
    ],
    data() {
        return {
            subscribers:[],
            total:this.subscribedCount,
            pagerCount:Math.ceil(this.total / 60),
            flag:false,
        };
    },
    computed: {

    },
    created() {
        this.getPlaylistSubscribers(0)
    },
    mounted() {

    },
    watch: {

    },
    methods: {
        getPlaylistSubscribers(offset){
            _getPlaylistSubscribers(this.$route.query.id,offset)
            .then(res => {
                this.subscribers = res.data.subscribers
            })
        },
        show(){
            this.flag = true
        },
        pageChange(index){
            this.getPlaylistSubscribers(index-1)
        }
    },
    filters:{
        nickNameFormat(el){
            if(el.length > 7){
                return el.slice(0,7) + '...'
            }
            return el
        }
    },
    components: {

    },
};
</script>

<style scoped lang="less">
.position_flex(@jc:space-between,@ai:center){
  display: flex;
  align-items: @ai;
  justify-content: @jc;
}
.subscribers{
    .position_flex(flex-start);
    flex-wrap: wrap;
    position: relative;
    .subscriber{
        width: 10%;
        margin: 30px 0;
        img{
        width: 80px;
        height: 80px;
        border-radius: 50%;
        margin-left: 50%;
        transform: translateX(-50%);
        }
        .name{
            text-align: center;
            font-size: 14px;
        }
    }
    @media screen and (min-width: 768px) and (max-width: 1024px){
        .subscriber{
            width: 20%;
        }
    }
    @media screen and (min-width: 1024px) and (max-width: 1200px){
        .subscriber{
            width: 15%;
        }
    }
    .paging{
        margin-left: 50%;
        transform: translateX(-50%);
        margin-bottom: 20px;
        
    }
    
}
</style>
